﻿#ifndef _SERIAL_FILE_DISK_H_
#define _SERIAL_FILE_DISK_H_

#include "serial_file_base.h"
//裸磁盘文件
class CSerialFileRaw: public CSerialFileBase
{
public:
	CSerialFileRaw();
	~CSerialFileRaw();
public:
	//实现类似文件操作最基本的5个API fopen, fclose,fwrite,fread,fseek.
	virtual int Open(const char * file,uint64_t fileLBA, uint32_t fileSpace, int acess_mod) ;

	virtual int Close();
	virtual int ReOpen();
	virtual int Seek(int32_t offset,int whence);

	virtual int Read (uchar_t * pBuf, uint32_t dataSize, bool bLock = true);

	virtual int Write(uchar_t * pBuf, uint32_t dataSize, bool bLock = true);

	virtual int ReadPos(uint32_t offset, uchar_t * pBuf, uint32_t dataSize, bool bLock = true) ;

	virtual int WritePos(uint32_t offset, uchar_t * pBuf, uint32_t dataSize, bool bLock = true) ;

	//主要是录像专用的接口
	virtual int WriteCachePos(uint32_t offset, uchar_t * pBuf, uint32_t dataSize, bool bLock = true);

	virtual void Flush();

	virtual CDisk_Dev * GetDiskDev()
	{
		return m_pDev;
	}
	virtual uint32_t get_cur_offset(bool bReal = false)
	{
		return m_cur_offset;
	}
protected:
	CDisk_Dev *  m_pDev;
};

#endif
